-
Notifications
You must be signed in to change notification settings - Fork 8.2k
pinctrl: initial support for GD32 #39974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
43d42a5 to
f87f1b7
Compare
|
Hi @gmarull , I tested using |
nandojve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nandojve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gmarull ,
After some fixes AFIO is working:
*** Booting Zephyr OS build v2.7.99-1382-g31b26bab517c ***
Running test suite pinctrl_gd32
===================================================================
START - test_dt_extract
PASS - test_dt_extract in 0.1 seconds
===================================================================
Test suite pinctrl_gd32 succeeded
===================================================================
PROJECT EXECUTION SUCCESSFUL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bias-high-impedance is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option is not required, same as STM32 (see https://github.com/zephyrproject-rtos/zephyr/blob/main/dts/bindings/pinctrl/st%2Cstm32-pinctrl.yaml#L18). Not setting any bias and operating as input would be sufficient as far as I understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not setting any bias and operating as input would be sufficient as far as I understand.
I understand not setting any bias, which means bias-disable (default state), equals Analog. We should not work with a hidden state because people can made confusion. The configuration table have 4 options for Input and there are 3 options defined. If you look at
zephyr/dts/bindings/pinctrl/pincfg-node.yaml
Lines 25 to 28 in a5c2a61
| bias-high-impedance: | |
| required: false | |
| type: boolean | |
| description: high impedance mode ("third-state", "floating") |
Input Floating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that analog is treated via the pinmux value as a separate mode, not as an input mode. In case of DAC (an output signal), ANALOG still has to be used. For low-power mode, what is usually done is to set the analog mode (default config) on a pin, this is why I added the analog option for all pins in the generator:
/* ANALOG */
#define ANALOG_PA0 \
GD32_PINMUX_AFIO('A', 0, ANALOG, NORMP)
#define ANALOG_PA1 \
GD32_PINMUX_AFIO('A', 1, ANALOG, NORMP)
...
I know it can be a bit confusing, it's really STM32 inheritance (it's done this way, see for example https://elixir.bootlin.com/linux/latest/source/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi#L62). I think that treating analog in a special way makes things more understandable when it comes to the analog signals, but not that clear for low-power modes. In such case, it would probably make more sense to configure the pin as an input and set bias-high-impedance. But familiarity with STM32 has value for users experienced in that platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, it is important give some background for users. The information you presented at last comment is relevant to users understand how this should be configured. Other important thing is that no one can determine from where user will start to read the documentation. I think it could be very valuable improve documentation and try connect those things. For instance, correlate the GPIO configuration table with the options available can be very valuable to users. The same way, explain to then the why Analog is configured differently will help. Maybe provide pointer that exists in Zephyr can help to. Take in consideration that a lot of users don't know Linux and devicetree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the bindings description explaining more details on low power modes, please check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bias-high-impedance is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bias-disable: Disable pull-up/down (default, not required).
What is this? Analog or High-Impedance? Again, it is not clear the meaning and it is possible improve here to a very clear pin state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bias-high-impedance is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
e4690d7 to
4799cd9
Compare
3b01287 to
c8f784d
Compare
|
@cameled reviews welcome |
c8f784d to
d49b8eb
Compare
f9374d2 to
9ed980d
Compare
nandojve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gmarull ,
Thank you for this PR!
mbolivar-nordic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't review this very closely, but it looks like it's following all the latest practices from a quick skim.
9ed980d to
1f9d963
Compare
Include the module `include` folder to allow access to the dt-bindings helpers. Signed-off-by: Gerard Marull-Paretas <[email protected]>
Add a pin control driver for GD32 SoCs using the AF model. Signed-off-by: Gerard Marull-Paretas <[email protected]>
Add definitions for the pinctrl and gpio nodes. Signed-off-by: Gerard Marull-Paretas <[email protected]>
GD32F4XX series have AF based pinmux. Signed-off-by: Gerard Marull-Paretas <[email protected]>
Add a pin control driver for GD32 SoCs using the AFIO model. Thanks to Gerson Fernando Budke for testing and implementation suggestions. Co-authored-by: Gerson Fernando Budke <[email protected]> Signed-off-by: Gerard Marull-Paretas <[email protected]>
Add afio, pinctrl and gpioa...g entries for the GD32F403 series. Signed-off-by: Gerard Marull-Paretas <[email protected]>
GD32F403 series use AFIO pinmux model. Signed-off-by: Gerard Marull-Paretas <[email protected]>
Enable pinctrl by default, since it is an essential component on almost every firmware. Inclusion of series defconfig has also been guarded with SoC availability (was missing). Signed-off-by: Gerard Marull-Paretas <[email protected]>
Use the pinctrl API to configure peripheral pins. Signed-off-by: Gerard Marull-Paretas <[email protected]>
Enable usage of the pinctrl driver. Signed-off-by: Gerard Marull-Paretas <[email protected]>
Enable usage of pinctrl. Signed-off-by: Gerard Marull-Paretas <[email protected]>
Add a test to check that DT information for AF model is extracted correctly. Signed-off-by: Gerard Marull-Paretas <[email protected]>
Add a test to check that DT information for the AFIO model is extracted correctly. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1f9d963 to
148b495
Compare
This PR adds a new pinctrl driver for GD32 SoCs for both AF and AFIO pinmux models.
Tested on:
It depends on: